See Also

Tcp Class  | Tcp Members  | Overload List

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

buffer
Source memory location for the data to send.
See Also Languages PowerTCP SSL Sockets for .NET

Send(Byte[]) Method

Dart.PowerTCP.SslSockets Namespace > Tcp Class > Send Method : Send(Byte[]) Method

Send data to the server.

[Visual Basic]
<DescriptionAttribute("Send data from your buffer.")> Overloads Public Function Send( _    ByVal buffer() As Byte _ ) As Segment
[C#]
[DescriptionAttribute("Send data from your buffer.")] public Segment Send(    byte[] buffer );
[C++]
[DescriptionAttribute("Send data from your buffer.")] public: Segment* Send(    byte[]* buffer )
[C++/CLI]
[DescriptionAttribute("Send data from your buffer.")] public: Segment^ Send(    bytearray<buffer>^ buffer )

Parameters

buffer
Source memory location for the data to send.

Return Type

A Segment object encapsulating information about the data sent.

Exceptions

ExceptionDescription
ArgumentOutOfRangeExceptionoffset or count is less than 0.
ArgumentExceptionoffset + count is greater than the length of buffer.
SocketExceptionThe socket is not connected.

Remarks

After connecting, data can be received using the Send method. All Send methods return a Segment object, encapsulating information about the data sent such as the data sent, and the amount of bytes of data sent.

This method is functionally equivalent to Tcp.Stream.Write(byte[]).

Example

The following example demonstrates sending bytes to the server.

[Visual Basic] 

Private Sub Test()
   ' Connect to an echo port
   Tcp1.Connect("atropos", 7)

   Dim sendbuffer() As Byte = System.Text.Encoding.Default.GetBytes("abcdefg")

   ' Send some bytes.
   Tcp1.Send(sendbuffer)

   Dim recvbuffer(sendbuffer.Length) As Byte

   ' Server will echo the bytes back. Receive the bytes.
   Tcp1.Receive(recvbuffer)

   ' Close the connection.
   Tcp1.Close()
End Sub

[C#] 


private void Test()
{
  
// Connect to the echo port
  
tcp1.Connect("atropos", 7);

  
byte[] sendbuffer = System.Text.Encoding.Default.GetBytes("abcdefg");

  
// Send some bytes.
  
tcp1.Send(sendbuffer);

  
byte[] recvbuffer = new byte[sendbuffer.Length];

  
// Server will echo the bytes back. Receive the bytes.
  
tcp1.Receive(recvbuffer);

  
// Close the connection.
  
tcp1.Close();
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Tcp Class  | Tcp Members  | Overload List


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.